from werkzeug.utils import find_modules, import_string

from utils.work_log import get_logger

log = get_logger(__name__)


def register_blueprints(_app, path='api'):
    """
    注册蓝图
    :param _app:
    :param path: 接口文件路径
    :return:
    """
    """Register all blueprint modules"""
    for name in find_modules(path, recursive=True):
        log.info('注册blueprint bp=%s', name)
        module = import_string(name)
        if hasattr(module, path):
            _app.register_blueprint(module.api)
